package com.ruoyi.zsyh.controller.applet.user;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.zsyh.domain.ZsyhUserBanner;
import com.ruoyi.zsyh.service.IZsyhUserBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 首页banner管理Controller
 * 
 * @author zhangkm
 * @date 2022-2-21
 */
@Controller
@RequestMapping("/applet/zsyh/userBanner")
public class ZsyhUserBannerAppletController extends BaseController
{

    @Autowired
    private IZsyhUserBannerService zsyhUserBannerService;

    /**
     * 获取banner列表
     * @return
     * @throws Exception
     */
    @RequestMapping("/getUserBanner")
    @ResponseBody
    public AjaxResult getUserBanner()throws Exception
    {
        ZsyhUserBanner banner = new ZsyhUserBanner();
        banner.setBannerState("1");
        List<ZsyhUserBanner> list = zsyhUserBannerService.selectZsyhUserBannerList(banner);
        if(list.size() > 0 ){
            return AjaxResult.success("操作成功", list);
        }else{
            return AjaxResult.error("暂无banner");
        }
    }


    /**
     * 获取banner详情
     * @return
     * @throws Exception
     */
    @RequestMapping("/getUserBannerById")
    @ResponseBody
    public AjaxResult getUserBannerById(String id)throws Exception
    {
        ZsyhUserBanner banner = zsyhUserBannerService.selectZsyhUserBannerById(id);
        return AjaxResult.success("成功", banner);
    }


}
